﻿using Microsoft.Extensions.DependencyInjection;
using Modules.Project.Repositories;
using PmSoft;

namespace Modules.Project
{
    [UseDI(ServiceLifetime.Scoped)]
    public class ProjectGuaranteeExpenditureDetailService
    {
        private readonly ProjectGuaranteeExpenditureDetailRepository repository;

        public ProjectGuaranteeExpenditureDetailService(ProjectGuaranteeExpenditureDetailRepository repository)
        {
            this.repository = repository;
        }

        public ProjectGuaranteeExpenditureDetail? GetProjectGuaranteeExpenditureDetail(int id)
        {
            return repository.Get(id);
        }

        public void Create(ProjectGuaranteeExpenditureDetail entity)
        {
            repository.Insert(entity);
        }

        public void Update(ProjectGuaranteeExpenditureDetail entity)
        {
            repository.Update(entity);
        }

        public IEnumerable<ProjectGuaranteeExpenditureDetail> GetProjectGuaranteeExpenditureDetailsByGuaranteeExpenditureId(int guaranteeExpenditureId)
        {
            return repository.GetProjectGuaranteeExpenditureDetailsByGuaranteeExpenditureId(guaranteeExpenditureId);
        }

        public void Delete(int id)
        {
            repository.DeleteByEntityId(id);
        }

        public void Deleted(IEnumerable<int> ids)
        {
            foreach (int id in ids)
            {
                Delete(id);
            }
        }
    }
}